package com.itheima.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.common.MessageConst;
import com.itheima.entity.Result;
import com.itheima.service.MemberService;
import com.itheima.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.Map;

@RestController
@RequestMapping("/report")
@Slf4j
public class ReportController {

    @Reference
    MemberService memberService;

    @Reference
    SetmealService setmealService;

    @RequestMapping("/getSetmealReport")
    public Result getSetmealReport(){
        Map<String, Object> map = setmealService.getSetmealReport();
        return new Result(true,MessageConst.GET_SETMEAL_COUNT_REPORT_SUCCESS,map);
    }


    @RequestMapping("/getMemberReport")
    public Result getMemberReport() throws ParseException {
        Map<String,Object> map = memberService.getYearAndMemberCount();
        return new Result(true, MessageConst.GET_MEMBER_NUMBER_REPORT_SUCCESS,map);
    }

}
